package com.czk.model.iterator.practice;

import java.util.Iterator;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/6/17 22:09
 */
public class ResearchDevelopment  implements Company{
    // 数组迭代器
    private Person[] people;
    // 添加数组的下标
    private int number=0;
    @Override
    public String getName() {
        return "研发部";
    }

    public ResearchDevelopment() {
        people=new Person[5];
        addPerson(new Person("陈彰坤",26));
        addPerson(new Person("吴丹",25));
        addPerson(new Person("杨雪",20));
        addPerson(new Person("黄娟",25));
        addPerson(new Person("蒋海霞",25));
    }

    @Override
    public void addPerson(Person person) {
        people[number]=person;
        number++;
    }

    @Override
    public Iterator iterator() {
        return new ResearchDevelopmentIterator(new ResearchDevelopment());
    }
    // 拿到数组集合
    public Person[] getPeople() {
        return people;
    }
}
